<template>
  <div class="container">
    <div>
      <header id="header" class="mui-bar mui-bar-nav">
        <button class="mui-btn mui-btn-link mui-btn-nav mui-pull-left" @click="goBack"> <span
            class="mui-icon mui-icon-left-nav" style="color: #000000;"></span></button>
        <p class="title">我的订单</p>
      </header>
    </div>
    <div class="list">
      <div class="card" v-for="item in order" @click="del(item)">
        <div class="imgList flex">
          <div class="goods_img_box" v-for="info in item.list">
            <img class="img" :src="info.url" />
          </div>
          <div class="alignRight">
            <strong class="red">{{item.price | money}}</strong>
            <p class="time">{{item.time}}</p>
          </div>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
  import {
    mapState,
    mapGetters
  } from 'vuex'
  export default {
    methods: {
      goBack() {
        this.$router.push('/My')
        this.$store.state.onHomePage = true
      },
      del(item){
        var index = this.order.indexOf(item)
        this.$store.commit('order/delOrder', index)
      }
    },
    computed: {
      ...mapState('order', ['order', 'detail']),
      ...mapGetters('shopcart', {
        total: 'getTotalGoodsCount',
        totalPrice: 'getTotalPrice',
        totalSelected: 'getTotalSelected',
        selectedList: 'getSelectedList'
      }),
    },
    filters: {
      money(str) {
        return '¥' + str
      }
    }
  }
</script>

<style scoped>
  .container {
    background-color: #eee;
  }

  .flex {
    display: flex;
  }

  .red {
    color: brown;
  }

  .title {
    font-size: 20px;
    font-weight: 420;
    margin-top: 12px;
    color: #000000;
  }
  .list{
    margin-top: 60px;
  }

  .card {
    margin-top: 20px;
    background-color: white;
    border-radius: 17px;
    margin-left: 15px;
    margin-right: 15px;
    padding-top: 5px;
    padding-left: 4px;
    height: 75px;
  }

  .goods_img_box {
    width: 50px;
    height: 50px;
    margin-left: 10px;
    margin-top: 7px;
  }

  .img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
  }

  .alignRight {
    position: fixed;
    right: 5%;
  }
  .time{
    margin-top: 20px;
  }
</style>
